-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Baggage and Tags for activity tracking options (#46571) #48722
Baggage and Tags for activity tracking options (#46571) #48722
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @maryamariyan Issue Details@tarekgh here we go. It's the simplest implementation I can think of. Tests will follow. * Is there a reason the
|
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
Also, could you please add tests for this added functionality? runtime/src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs Line 171 in cbb5b90
|
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
CC @davidfowl |
I don't think it has to implement |
Of course. Its on my TODO-list.
Okay. Should I change from |
Thank you.
Not important to do so for now. |
@msallin did you have a chance to address the remaining feedback so we can move on? |
5eb3df4
to
58b9152
Compare
Wasn't able yet do run the unit tests locally and I'm sure they fail. |
Let me know if you need help with that. |
58b9152
to
83b67c4
Compare
@msallin looks there is some errors https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-48722-merge-5b4b06b341d4447e9f/Microsoft.Extensions.Logging.Tests/console.edeb4dfd.log?sv=2019-07-07&se=2021-03-22T19%3A14%3A10Z&sr=c&sp=rl&sig=dUgpUHJSMEj0keRHUAiXUeIVIrGKg4F81mABpiBDnEA%3D Looks you missed updating the line
|
83b67c4
to
703a705
Compare
Here we go. Now I've something we can work with/discuss.
This can be seen by looking at the test: runtime/src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs Line 334 in 79ae74f
Or in the SimpleConsoleFormatter: runtime/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs Line 195 in 79ae74f
The JsonConsoleFormatter e.g. would behave correctly: runtime/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatter.cs Line 116 in 79ae74f
Either the runtime/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs Lines 79 to 80 in 79ae74f
What do we do if tag or baggage value is null? What do we do if the key of a baggage or tag is empty (is it even possible)? |
src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs
Outdated
Show resolved
Hide resolved
The other option which I am inclining to is to add the Tags and Baggage to
I believe it is ok to produce empty string at that time.
It is possible, at that time we'll produce empty string for the key. As I suggested, if we move the formatting logic to |
We have the activity as ctor param. You mean I should create a field and hold the |
Regarding the debugger output of activity accessing, it looks it is using the activity you have created which make sense. But still, something unclear to me.
These two lines means the object
means the cached value of |
We don't cache the values. We always reenumerate the IEnumerable. This would cache the values: |
You are right. I was assuming Activity.Baggage internally returning a list but it looks not. |
@msallin please let me know when you address the remaining comments and we'll be good to go. thanks! |
@tarekgh I think there aren't any comments left. |
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs
Outdated
Show resolved
Hide resolved
@msallin sorry it was my fault that I wrote the comments and didn't submit it. I posted them now. Thanks! |
Great! Ty! Consider them done until the end of this week. |
315c462
to
0e98759
Compare
@tarekgh I addressed all the comments. You might have a look again at the PR again and let me know if there is something I should rework. |
src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Outdated
Show resolved
Hide resolved
@msallin looks good to me. I have added one last minor comment and we'll be good to merge. |
0e98759
to
11b8166
Compare
|
11b8166
to
7e64b80
Compare
@msallin thanks a lot for helping with this issue. |
@tarekgh here we go. It's the simplest implementation I can think of.
As stated in #47315 a logging scope is expected to be
IEnumerable<KeyValuePair<string, object>>
*Tags and baggage are already
IEnumerable<KeyValuePair<string, object>>
and can be used.It makes no sense to cache them like it's done for the ActivityLogScope, as they change from one log line to the other.
Tests will follow.
* Is there a reason the
ActivityLogScope
implementsIReadOnlyList<T>
?